home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_paren.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.5 KB  |  22 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Fixer that addes parentheses where they are required
  5.  
  6. This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.'''
  7. from  import fixer_base
  8. from fixer_util import LParen, RParen
  9.  
  10. class FixParen(fixer_base.BaseFix):
  11.     PATTERN = "\n        atom< ('[' | '(')\n            (listmaker< any\n                comp_for<\n                    'for' NAME 'in'\n                    target=testlist_safe< any (',' any)+ [',']\n                     >\n                    [any]\n                >\n            >\n            |\n            testlist_gexp< any\n                comp_for<\n                    'for' NAME 'in'\n                    target=testlist_safe< any (',' any)+ [',']\n                     >\n                    [any]\n                >\n            >)\n        (']' | ')') >\n    "
  12.     
  13.     def transform(self, node, results):
  14.         target = results['target']
  15.         lparen = LParen()
  16.         lparen.set_prefix(target.get_prefix())
  17.         target.set_prefix('')
  18.         target.insert_child(0, lparen)
  19.         target.append_child(RParen())
  20.  
  21.  
  22.